package com.imay.live.activity.family.controller;

import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.imay.live.R;
import com.imay.live.activity.RoomLiveNormalActivity;
import com.imay.live.adapter.DiscoveryAdapter;
import com.imay.live.model.RoomInfoModel;
import com.imay.live.utils.ViewUtil;

import java.util.ArrayList;

import static org.cocos2dx.lib.Cocos2dxHelper.getActivity;

/**
 * Created by Administrator on 2017/9/11 0011.
 */

public class FamilyLiveController extends BaseFamilyController {

    RecyclerView rcv_content;
    private DiscoveryAdapter mAdapter;

    @Override
    protected void initView() {
        rcv_content = ViewUtil.findView(activity, R.id.rcv_content);
        GridLayoutManager gridLayoutManager = new GridLayoutManager(activity, 2);
        rcv_content.setLayoutManager(gridLayoutManager);
        rcv_content.setHasFixedSize(true);
        mAdapter = new DiscoveryAdapter(null);
        rcv_content.setAdapter(mAdapter);
        mAdapter.setOnItemChildClickListener(new BaseQuickAdapter.OnItemChildClickListener() {
            @Override
            public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
                if (view.getId() == R.id.discover_live_rl_square) {
                    RoomLiveNormalActivity.startActivity(getActivity(), (ArrayList<RoomInfoModel>) adapter.getData(), position);
                }
            }
        });
    }
}
